<?php

namespace app\common\library;

use League\Flysystem\Filesystem;
use League\Flysystem\FilesystemException;
use Overtrue\Flysystem\Qiniu\QiniuAdapter;
use Overtrue\Flysystem\Qiniu\Plugins\FetchFile;

class Qiniuyun
{

    public static function upload()
    {
        $accessKey = '98kAT6wfaeRAta6_kv1jjQp7vNwMEZ0NJie9a94w';
        $secretKey = 'yQ7_uRQIvqJOx9izNj2JP0vwTUmAIXZjMhdDkmZG';
        $bucket = 'cdsjbj';
        $domain = 'http://qiniu.shangjiubj.com'; // or with protocol: https://xxxx.bkt.clouddn.com


        
        try{
            $adapter = new QiniuAdapter($accessKey, $secretKey, $bucket, $domain);

            $flysystem = new Filesystem($adapter);
            $res = $flysystem->write('1234.jpg',file_get_contents('./1111.jpg'));
            
        }catch(\Exception $e){
            return $e->getMessage();
        }

       

        return 'ok';
        
    }
}
